home *** CD-ROM | disk | FTP | other *** search
- #include "Retrace.h"
- #include "Start.h"
- #include "Gestalt.h"
- #include "Mad.h"
- #include "RDriver.h"
- #include "sound.h"
- #include "EPPC.h"
-
- #define VERSION 0x0454
- #define PLAYERPREF "\pPlayerPRO Prefs"
-
- void DoPreferences2();
- void SetDText (DialogPtr dlog, short item, Str255 str);
-
- MADDriverRec *MADDriver;
-
- #if defined(powerc) || defined (__powerc)
- #pragma options align = mac68k
- #endif
-
- typedef struct
- {
- short Version;
- Boolean Loop;
- Boolean Stereo;
- Boolean PPCMachine;
- Boolean xxxxxxxx;
- Fixed Frequence;
- Boolean LargeWindow;
- Boolean AutoCreator;
- Boolean MicroRecording;
- short oldShort;
- Boolean AffichageDIGI;
- short NoStart;
- Point WinPos[ 30];
- short WinEtat[ 30];
- short PianoKey[ 300];
- Boolean oldBool;
- Boolean InstruListBig;
- Boolean PatListBig;
- Boolean AutoScroll;
- short LoopType;
- short WinHi[30];
- Boolean val;
- long sL;
- Byte notUsed;
- Str32 name;
- long sum;
- long Mz;
- unsigned long firstStart;
- short WinLarg[30];
- RGBColor tracksColor[ 32];
- short tracksColorID[ 32];
- short PianoPos;
- short volumeLevel;
- Boolean MADCompression;
- Boolean SSText;
- Boolean SSStars;
- Boolean SSJumping;
- Boolean FText;
- Boolean FStars;
- Boolean FBalls;
- short TextS;
- Boolean ThreadUse;
- Boolean FSinScroll;
- Boolean RememberMusicList;
- Boolean ddddddddd;
- long WinID[ 30];
- Boolean DigitalInstru;
- Boolean DigitalNote;
- Boolean DigitalEffect;
- Boolean DigitalArgu;
- Boolean DigitalVol;
- Boolean GoToStop;
- Boolean DriverEffects[ 20];
- Boolean MADC;
- short OscilloSize;
- short OscilloType;
- short fileTypeExportSND;
- OSType CompressionExportSND;
- Boolean ActiveHelp;
- short SpectrumSize;
- short SpectrumType;
-
- /** Driver Settings **/
-
- short numChn; // Active tracks from 2 to 32, automatically setup when a new music is loaded
- short outPutBits; // 8 or 16 Bits
- unsigned long outPutRate; // Fixed number, by example : rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
- short outPutMode; // MonoOutPut, StereoOutPut or DeluxeStereoOutPut ?
- short driverMode; // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
- Boolean antiAliasing; // Use AntiAliasing filter ?
-
- /** Mozart Prefs **/
-
- Boolean UseOctaveMarkers;
- Boolean UseMarkers;
- short MarkersSize;
- short MarkersOffSet;
- short MozartX;
-
- /** News 4.5 **/
-
- Boolean SpectrumScale;
- Boolean ClassicalProjection;
- Boolean PianoOctaveMarkers;
- Boolean SmallPiano;
- Boolean FastMusicList;
- long FastDigitalEdition;
-
- Boolean MacKeyBoard;
- Boolean MidiKeyBoard;
- Boolean QKMidiKeyBoard;
-
- Boolean MIDIVelocity;
- Boolean MIDIChanInsTrack;
-
- short KeyUpMode;
-
- /** News 4.5.1 **/
-
- Boolean Interpolation;
- Boolean MicroDelay;
- long MicroDelaySize;
- Boolean surround;
-
- /** News 4.5.2 **/
-
- Boolean OCArrow[ 128];
- short MozartC1h, MozartC2h;
- OSType SoundTypeSamp;
- OSType SoundTypeIns;
- short LinesHeight;
- Boolean SaveMusicList;
- short softVolumeLevel;
-
- Boolean ADAPremember;
- Boolean ADAPsave;
- Boolean ADAPuse;
-
- Boolean osciTile;
-
- Boolean addExtension;
-
- Boolean AutoPlayWhenOpen;
-
- Boolean Reverb;
- long ReverbSize;
- long ReverbStrength;
-
- Boolean DirectVideo;
-
- /** News 4.5.3 **/
-
- Boolean TickRemover;
- Boolean AutomaticOpen;
- Boolean FinePositioning;
-
- short ChannelType;
- short amplitude;
- OSType Compressor;
- Fixed FrequenceSpeed;
-
- Boolean RecordAllTrack;
-
- } Prefs;
- #if defined(powerc) || defined (__powerc)
- #pragma options align = reset
- #endif
-
- static Boolean Stereo, StereoMixing, NewSoundManager, has16Bit;
- static int VolumeH, SpeedH;
- static PixPatHandle workPixPat;
- Prefs thePrefs;
-
- DialogPtr myDialog;
-
- Boolean OnTourne;
-
-
- void MegaLoop( void);
- void ReadAndPlayMusic( Str255 myFile, OSType fdType);
- void SwitchDriverTo2();
-
- #include "Drag.h"
-
- #ifndef THINK_C
- static DragTrackingHandlerUPP MyTrackingUPP;
- static DragReceiveHandlerUPP MyReceiveUPP;
- #endif
-
- static Boolean canAcceptDrag;
-
- void pStrcat(register unsigned char *s1, register unsigned char *s2)
- {
- register unsigned char *p;
- register short len, i;
-
- if (*s1+*s2<=255)
- {
- p = *s1 + s1 + 1;
- *s1 += (len = *s2++);
- }
- else
- {
- *s1 = 255;
- p = s1 + 256 - (len = *s2++);
- }
- for (i=len; i; --i) *p++ = *s2++;
- }
-
- void InitDriverString()
- {
- Str255 str;
-
- if( MADDriver->DriverSettings.Reverb && MADDriver->DriverSettings.outPutMode != MonoOutPut)
- {
- NumToString( MADDriver->DriverSettings.ReverbSize, str);
- pStrcat( str, "\pms");
- SetDText( myDialog, 27, str);
-
- NumToString( MADDriver->DriverSettings.ReverbStrength, str);
- pStrcat( str, "\p%");
- SetDText( myDialog, 29, str);
- }
- else
- {
- SetDText( myDialog, 27, "\pOFF");
-
- NumToString( MADDriver->DriverSettings.ReverbStrength, str);
- pStrcat( str, "\p%");
- SetDText( myDialog, 29, str);
- }
-
- if( MADDriver->DriverSettings.MicroDelay && MADDriver->DriverSettings.outPutMode != MonoOutPut)
- {
- NumToString( MADDriver->DriverSettings.MicroDelaySize, str);
- pStrcat( str, "\pms");
- SetDText( myDialog, 7, str);
- }
- else SetDText( myDialog, 7, "\pDelay OFF");
-
- if( MADDriver->DriverSettings.surround && MADDriver->DriverSettings.outPutMode != MonoOutPut) SetDText( myDialog, 24, "\pSurround ON");
- else SetDText( myDialog, 24, "\pSurround OFF");
-
- if( MADDriver->DriverSettings.Interpolation) SetDText( myDialog, 22, "\pInterpolation ON");
- else SetDText( myDialog, 22, "\pInterpolation OFF");
-
- if( MADDriver->DriverSettings.TickRemover && MADDriver->DriverSettings.outPutMode != MonoOutPut) SetDText( myDialog, 31, "\pTick Remover ON");
- else SetDText( myDialog, 31, "\pTick Remover OFF");
-
- switch( MADDriver->DriverSettings.outPutRate)
- {
- case rate11khz: SetDText( myDialog, 10, "\p11 Khz"); break;
- case rate22khz: SetDText( myDialog, 10, "\p22 Khz"); break;
- case rate44khz: SetDText( myDialog, 10, "\p44 Khz"); break;
- }
-
- switch( MADDriver->DriverSettings.outPutMode)
- {
- case MonoOutPut: SetDText( myDialog, 13, "\pMono"); break;
- case StereoOutPut: SetDText( myDialog, 13, "\pStereo"); break;
- case DeluxeStereoOutPut: SetDText( myDialog, 13, "\pTrue Stereo"); break;
- }
- switch( MADDriver->DriverSettings.outPutBits)
- {
- case 8: SetDText( myDialog, 16, "\p8 bits"); break;
- case 16: SetDText( myDialog, 16, "\p16 bits"); break;
- }
-
- }
-
- void FrameRectRelief( Rect *theRect)
- {
- RGBColor theColor;
-
- #define GrisClair 0xFFFF
- #define GrisFonce 0x4000
-
- MoveTo( theRect->left, theRect->top);
-
- theColor.red = GrisFonce; theColor.blue = GrisFonce; theColor.green = GrisFonce;
- RGBForeColor( &theColor);
- LineTo( theRect->right, theRect->top);
-
- theColor.red = GrisClair; theColor.blue = GrisClair; theColor.green = GrisClair;
- RGBForeColor( &theColor);
- LineTo( theRect->right, theRect->bottom);
-
- theColor.red = GrisClair; theColor.blue = GrisClair; theColor.green = GrisClair;
- RGBForeColor( &theColor);
- LineTo( theRect->left, theRect->bottom);
-
- theColor.red = GrisFonce; theColor.blue = GrisFonce; theColor.green = GrisFonce;
- RGBForeColor( &theColor);
- LineTo( theRect->left, theRect->top);
-
-
- ForeColor( blackColor);
- }
-
- pascal OSErr MyTrackingTools(short message, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag)
- { short result;
- unsigned long attributes;
- ItemReference theItem;
- RgnHandle theRgn;
- Point theMouse, localMouse;
- FlavorFlags theFlags;
- long textSize;
- HFSFlavor myFlavor;
- FInfo fndrInfo;
- char str[ 5];
-
- if ((message != dragTrackingEnterHandler) && (!canAcceptDrag)) return( noErr);
-
- SetPort( theWindow);
-
- GetDragAttributes(theDrag, &attributes);
-
- switch (message) {
-
- case dragTrackingEnterHandler:
- canAcceptDrag = false;
-
- GetDragItemReferenceNumber(theDrag, 1, &theItem);
- result = GetFlavorFlags(theDrag, theItem, flavorTypeHFS, &theFlags);
- if (result == noErr)
- {
- GetFlavorDataSize( theDrag, theItem, flavorTypeHFS, &textSize);
-
- GetFlavorData( theDrag, theItem, flavorTypeHFS, &myFlavor, &textSize, 0L);
-
- HSetVol( 0L, myFlavor.fileSpec.vRefNum, myFlavor.fileSpec.parID);
- GetFInfo( myFlavor.fileSpec.name, 0, &fndrInfo);
-
-
- OSType2Ptr( fndrInfo.fdType, str);
-
- if( MADPlugAvailable( str)) canAcceptDrag = true;
- }
- break;
-
- case dragTrackingEnterWindow:
-
- break;
-
- case dragTrackingInWindow:
- //
- // We receive InWindow messages as long as the mouse is in one of our windows
- // during a drag. We draw the window highlighting and blink the insertion caret
- // when we get these messages.
- //
-
- GetDragMouse(theDrag, &theMouse, 0L);
- localMouse = theMouse;
- GlobalToLocal(&localMouse);
-
- //
- // Show or hide the window highlighting when the mouse enters or leaves the
- // TextEdit field in our window (we don't want to show the highlighting when
- // the mouse is over the window title bar or over the scroll bars).
- //
-
- if( PtInRect( localMouse, &myDialog->portRect))
- {
- RectRgn(theRgn = NewRgn(), &myDialog->portRect);
-
- ShowDragHilite(theDrag, theRgn, true);
- DisposeRgn(theRgn);
- }
- break;
-
- case dragTrackingLeaveWindow:
- HideDragHilite( theDrag);
- break;
-
- case dragTrackingLeaveHandler:
-
- break;
- }
-
- return(noErr);
- }
-
- pascal OSErr MyReceiveTools(WindowPtr theWindow, unsigned long handlerRefCon, DragReference theDrag)
- {
- HFSFlavor myFlavor;
- OSErr result;
- unsigned short items;
- ItemReference theItem;
- DragAttributes attributes;
- Size textSize;
- short index, mouseDownModifiers, mouseUpModifiers, moveInstru;
- FInfo fndrInfo;
- OSErr err;
-
- SetPort(theWindow);
-
- GetDragAttributes(theDrag, &attributes);
- GetDragModifiers(theDrag, 0L, &mouseDownModifiers, &mouseUpModifiers);
-
- moveInstru = (attributes & dragInsideSenderWindow) && (!((mouseDownModifiers & optionKey) | (mouseUpModifiers & optionKey)));
-
- HideDragHilite( theDrag);
-
- //
- // A file is coming...
- //
-
- CountDragItems(theDrag, &items);
-
- index = 1; // Take only 1 file
-
- GetDragItemReferenceNumber(theDrag, index, &theItem);
-
- result = GetFlavorDataSize(theDrag, theItem, flavorTypeHFS, &textSize);
-
- if (result == noErr)
- {
- GetFlavorData(theDrag, theItem, flavorTypeHFS, &myFlavor, &textSize, 0L);
-
- err = HGetFInfo( myFlavor.fileSpec.vRefNum, myFlavor.fileSpec.parID, myFlavor.fileSpec.name, &fndrInfo);
-
- if( err == noErr)
- {
- ReadAndPlayMusic( myFlavor.fileSpec.name, fndrInfo.fdType);
-
- return(noErr);
- }
- }
-
- return(dragNotAcceptedErr);
- }
-
- void MyDebugStr( Str255 aStr)
- {
- DebugStr( aStr);
- }
-
- void SetDText (DialogPtr dlog, short item, Str255 str)
- {
- Handle itemHandle;
- short itemType;
- Rect itemRect;
- Str255 myStr;
-
- GetDialogItem (dlog, item, &itemType, &itemHandle, &itemRect);
- if( itemHandle == 0L) MyDebugStr("\pError in SetDText");
-
- GetDialogItemText (itemHandle, myStr);
- if( RelString( myStr, str, true, true) != 0) SetDialogItemText (itemHandle, str);
- }
-
- void SetUpSize()
- {
- /*Handle hRsrc;
- long fileSize;
-
- hRsrc = GetResource( 'SIZE', -1);
- if( hRsrc == 0L) Debugger();
-
- HNoPurge( hRsrc);
- HLock( hRsrc);
-
- fileSize = *((long*)((*hRsrc)+2));
-
- fileSize -= FreeMem();
- fileSize += 20000L;
-
- *((long*)((*hRsrc)+2)) = (long) fileSize;
- *((long*)((*hRsrc)+6)) = (long) fileSize;
-
- ChangedResource( hRsrc);
- WriteResource( hRsrc);
-
- HUnlock( hRsrc);
- HPurge( hRsrc);
-
- ReleaseResource( (Handle) hRsrc);*/
- }
-
- void SKVolume( short vol)
- {
- Point tempL;
- long *tL;
-
- if(vol>8) vol = 8;
- if(vol<0) vol = 0;
-
- if( vol > 0)
- {
- if( NewSoundManager)
- {
- tempL.v = vol * 32L;
- tempL.h = vol * 32L;
-
- tL = (long*) &tempL;
- SetDefaultOutputVolume( *tL);
- }
- else SetSoundVol( vol - 1);
- }
-
- }
-
- short PressTypeMenu( short whichMenu, short item)
- {
- long mresult, r;
- Point Zone;
- short i, itemType, startitem;
- Handle itemHandle;
- Rect itemRect;
- MenuHandle MenuDriver;
- Str255 str;
-
- MenuDriver = GetMenu( whichMenu);
-
- for( i = 0 ; i < CountMItems( MenuDriver); i++) EnableItem( MenuDriver, i+1);
-
- InsertMenu( MenuDriver, hierMenu);
-
- GetDialogItem( myDialog, item, &itemType, &itemHandle, &itemRect);
- Zone.h = itemRect.left; Zone.v = itemRect.top;
-
- LocalToGlobal( &Zone);
-
- #define ApFontID *((short*) 0x984)
-
- i = ApFontID; ApFontID = 4;
-
- switch( whichMenu)
- {
- case 128:
- if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut) DisableItem( MenuDriver, 2);
-
-
- if( MADDriver->DriverSettings.surround && MADDriver->DriverSettings.outPutMode != MonoOutPut) startitem = 2;
- else startitem = 1;
- break;
-
- case 129:
- if( MADDriver->DriverSettings.Interpolation) startitem = 2;
- else startitem = 1;
- break;
-
- case 130:
- if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut) DisableItem( MenuDriver, 2);
-
- if( MADDriver->DriverSettings.TickRemover) startitem = 2;
- else startitem = 1;
- break;
-
- case 165:
- if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut)
- {
- for( i = 1 ; i < CountMItems( MenuDriver); i++) DisableItem( MenuDriver, i+1);
- }
-
- if( MADDriver->DriverSettings.MicroDelay && MADDriver->DriverSettings.outPutMode != MonoOutPut)
- {
- startitem = 2;
- for( i = 1 ; i < CountMItems( MenuDriver); i++)
- {
- Str255 str;
- long r;
-
- GetMenuItemText( MenuDriver, i+1, str);
-
- str[ 0] -= 3; StringToNum( str, &r); str[ 0] += 3;
-
- if( r == MADDriver->DriverSettings.MicroDelaySize) startitem = i+1;
- }
- }
- else startitem = 1;
- break;
-
- case 170:
- if( !Stereo || MADDriver->DriverSettings.outPutMode == MonoOutPut)
- {
- for( i = 1 ; i < CountMItems( MenuDriver); i++) DisableItem( MenuDriver, i+1);
- }
-
- if( MADDriver->DriverSettings.Reverb && MADDriver->DriverSettings.outPutMode != MonoOutPut)
- {
- startitem = 2;
- for( i = 1 ; i < CountMItems( MenuDriver); i++)
- {
- Str255 str;
- long r;
-
- GetMenuItemText( MenuDriver, i+1, str);
-
- str[ 0] -= 3; StringToNum( str, &r); str[ 0] += 3;
-
- if( r == MADDriver->DriverSettings.ReverbSize) startitem = i+1;
- }
- }
- else startitem = 1;
- break;
-
- case 169:
- startitem = 2;
- for( i = 0 ; i < CountMItems( MenuDriver); i++)
- {
- Str255 str;
- long r;
-
- GetMenuItemText( MenuDriver, i+1, str);
-
- str[ 0] -= 2; StringToNum( str, &r); str[ 0] += 2;
-
- if( r == MADDriver->DriverSettings.ReverbStrength) startitem = i+1;
- }
- break;
-
- case 131:
- if( !has16Bit) { DisableItem( MenuDriver, 3);}
-
- switch( MADDriver->DriverSettings.outPutRate)
- {
- default:
- case rate11khz: startitem = 1; break;
- case rate22khz: startitem = 2; break;
- case rate44khz: startitem = 3; break;
- }
- break;
-
- case 132:
- if( !Stereo) { DisableItem( MenuDriver, 2); DisableItem( MenuDriver, 3);}
-
- switch( MADDriver->DriverSettings.outPutMode)
- {
- default:
- case MonoOutPut: startitem = 1; break;
- case StereoOutPut: startitem = 2; break;
- case DeluxeStereoOutPut: startitem = 3; break;
- }
- break;
-
- case 133:
- if( !has16Bit) { DisableItem( MenuDriver, 2); }
-
- switch( MADDriver->DriverSettings.outPutBits)
- {
- default:
- case 8: startitem = 1; break;
- case 16: startitem = 2; break;
- }
- break;
- }
- mresult = PopUpMenuSelect( MenuDriver,
- Zone.v,
- Zone.h,
- startitem);
- ApFontID = i;
-
- if( HiWord( mresult) != 0)
- {
- Boolean IsPlaying;
- long speedCopy;
-
- IsPlaying = MADDriver->Reading;
- if( IsPlaying) speedCopy = MADDriver->speed;
- MADDriver->Reading = false;
-
- if( MADStopDriver() != noErr) ExitToShell();
- if( MADDisposeDriver() != noErr) ExitToShell();
-
- switch( whichMenu)
- {
- case 131:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.outPutRate = rate11khz; break;
- case 2: MADDriver->DriverSettings.outPutRate = rate22khz; break;
- case 3: MADDriver->DriverSettings.outPutRate = rate44khz; break;
- }
- break;
-
- case 132:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.outPutMode = MonoOutPut; break;
- case 2: MADDriver->DriverSettings.outPutMode = StereoOutPut; break;
- case 3: MADDriver->DriverSettings.outPutMode = DeluxeStereoOutPut; break;
- }
- break;
-
- case 133:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.outPutBits = 8; break;
- case 2: MADDriver->DriverSettings.outPutBits = 16; break;
- }
- break;
-
- case 128:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.surround = false; break;
- case 2: MADDriver->DriverSettings.surround = true; break;
- }
- break;
-
- case 129:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.Interpolation = false; break;
- case 2: MADDriver->DriverSettings.Interpolation = true; break;
- }
- break;
-
- case 130:
- switch( LoWord( mresult))
- {
- default:
- case 1: MADDriver->DriverSettings.TickRemover = false; break;
- case 2: MADDriver->DriverSettings.TickRemover = true; break;
- }
- break;
-
- case 165:
- if( LoWord( mresult) == 1)
- {
- MADDriver->DriverSettings.MicroDelay = false;
- }
- else
- {
- MADDriver->DriverSettings.MicroDelay = true;
-
- GetMenuItemText( MenuDriver, LoWord( mresult), str);
- str[ 0] -= 3;
- StringToNum( str, &r);
- str[ 0] += 3;
-
- if( r >= 0 && r <= 1000) MADDriver->DriverSettings.MicroDelaySize = r;
- }
- break;
-
- case 170:
- if( LoWord( mresult) == 1)
- {
- MADDriver->DriverSettings.Reverb = false;
- }
- else
- {
- MADDriver->DriverSettings.Reverb = true;
-
- GetMenuItemText( MenuDriver, LoWord( mresult), str);
- str[ 0] -= 3;
- StringToNum( str, &r);
- str[ 0] += 3;
-
- if( r >= 0 && r <= 1000) MADDriver->DriverSettings.ReverbSize = r;
- }
- break;
-
- case 169:
- GetMenuItemText( MenuDriver, LoWord( mresult), str);
- str[ 0] -= 2;
- StringToNum( str, &r);
- str[ 0] += 2;
-
- if( r >= 0 && r <= 1000) MADDriver->DriverSettings.ReverbStrength = r;
- break;
-
-
- }
- if( MADCreateDriver( &MADDriver->DriverSettings) != noErr) ExitToShell();
-
- InitDriverString();
-
- MADStartDriver();
-
- if( IsPlaying)
- {
- MADDriver->speed = speedCopy;
- MADDriver->Reading = true;
- }
- DeleteMenu( (*MenuDriver)->menuID);
- return 0;
- }
- else
- {
- DeleteMenu( (*MenuDriver)->menuID);
- return -1;
- }
- }
-
- void SwitchDriverTo2()
- {
- Boolean IsPlaying;
- long speedCopy;
-
- IsPlaying = MADDriver->Reading;
- if( IsPlaying) speedCopy = MADDriver->speed;
- MADDriver->Reading = false;
-
- if( MADStopDriver() != noErr) ExitToShell();
- if( MADDisposeDriver() != noErr) ExitToShell();
-
-
- if( MADCreateDriver( &MADDriver->DriverSettings) != noErr) ExitToShell();
-
- MADStartDriver();
-
- if( IsPlaying)
- {
- MADDriver->speed = speedCopy;
- MADDriver->Reading = true;
- }
- }
-
- long oldTempL;
-
- void DrawTimeBar()
- {
- Rect itemRect;
- long tempL;
- long fullTime, curTime;
- short itemType, i;
- Handle itemHandle;
- Str255 aStr;
-
- GetDialogItem( myDialog, 4, &itemType, &itemHandle, &itemRect);
-
- MADGetMusicStatus( &fullTime, &curTime);
-
- tempL = ((long) (itemRect.right - itemRect.left) * curTime) / fullTime;
-
- if( tempL != oldTempL)
- {
- oldTempL = tempL;
-
-
- i = itemRect.right;
- itemRect.right = itemRect.left + tempL;
- if( itemRect.right > i) itemRect.right = i;
-
- ForeColor( blackColor);
- PaintRect( &itemRect);
-
- itemRect.left = itemRect.right;
- itemRect.right = i;
-
- ForeColor( whiteColor);
- PaintRect( &itemRect);
- ForeColor( blackColor);
-
- /**/
-
- GetDialogItem (myDialog, 4, &itemType, &itemHandle, &itemRect);
- MoveTo( itemRect.left + 2, itemRect.bottom - 1);
- TextMode( srcXor);
- if( tempL > 100) tempL = 100;
- NumToString( tempL, aStr); pStrcat( aStr, "\p %");
- DrawString( aStr);
- TextMode( srcCopy);
-
- /**/
-
- ForeColor( blackColor);
- }
- }
-
- void MegaLoop()
- {
- char theChar;
- EventRecord theEvent;
- short thePart, whichItem, oldH = 0;
- WindowPtr whichWindow;
- short itemType, temp;
- Rect itemRect;
- Handle itemHandle;
- DialogPtr whichDialog;
- Point Location, myPt;
- GrafPtr savePort;
- Str255 aStr;
-
- do
- {
- WaitNextEvent( everyEvent, &theEvent, 60L, 0L);
-
- if( theEvent.what == nullEvent)
- {
- GetPort( &savePort);
- SetPort( myDialog);
-
- DrawTimeBar();
-
- SetCursor( &qd.arrow);
-
- SetPort( savePort);
- }
- else if( theEvent.what == mouseDown)
- {
- switch( thePart = FindWindow( theEvent.where, &whichWindow))
- {
- case inContent:
- if( DialogSelect( &theEvent, &whichDialog, &whichItem ))
- {
- GetPort( &savePort);
- SetPort( whichDialog);
-
- switch( whichItem)
- {
- case 2:
- do
- {
- GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
- GetMouse( &Location);
-
- if( oldH != Location.h)
- {
- oldH = Location.h;
-
- if( Location.h < itemRect.left) Location.h = itemRect.left;
- else if ( Location.h > itemRect.right) Location.h = itemRect.right;
-
- VolumeH = Location.h - itemRect.left;
- itemRect.right = Location.h;
- PaintRect( &itemRect);
- GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
- itemRect.left = Location.h;
-
- ForeColor( whiteColor);
- PaintRect( &itemRect);
- ForeColor( blackColor);
-
- /**/
-
- GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
- MoveTo( itemRect.left + 2, itemRect.bottom - 1);
- TextMode( srcXor);
- NumToString( VolumeH, aStr); pStrcat( aStr, "\p %");
- DrawString( aStr);
- TextMode( srcCopy);
-
- /**/
-
- GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
-
- SKVolume( 1 + (8 * (Location.h - itemRect.left) / (itemRect.right - itemRect.left)));
- }
- }while( Button());
- break;
-
- case 18:
- do
- {
- GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
- GetMouse( &Location);
-
- if( oldH != Location.h)
- {
- oldH = Location.h;
-
- if( Location.h < itemRect.left) Location.h = itemRect.left;
- else if ( Location.h > itemRect.right) Location.h = itemRect.right;
-
- SpeedH = Location.h - itemRect.left;
- itemRect.right = Location.h;
- PaintRect( &itemRect);
- GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
- itemRect.left = Location.h;
-
- ForeColor( whiteColor);
- PaintRect( &itemRect);
- ForeColor( blackColor);
-
- /**/
-
- GetDialogItem (whichDialog, 18, &itemType, &itemHandle, &itemRect);
- MoveTo( itemRect.left + 2, itemRect.bottom - 1);
- TextMode( srcXor);
- NumToString( SpeedH*2, aStr); pStrcat( aStr, "\p %");
- DrawString( aStr);
- TextMode( srcCopy);
-
- /**/
-
- GetDialogItem (whichDialog, 2, &itemType, &itemHandle, &itemRect);
-
- MADDriver->VExt = (160 * (Location.h - itemRect.left)) / (itemRect.right - itemRect.left);
- if( MADDriver->VExt <= 0) MADDriver->VExt = 1;
- }
- }while( Button());
- break;
-
-
- case 4:
- temp = -1;
- do
- {
- GetDialogItem( whichDialog , 4, &itemType, &itemHandle, &itemRect);
- GetMouse( &myPt);
-
- if( temp != myPt.h)
- {
- if( myPt.h < itemRect.left) myPt.h = itemRect.left;
- else if ( myPt.h > itemRect.right) myPt.h = itemRect.right;
-
- MADSetMusicStatus( itemRect.left, itemRect.right, myPt.h);
-
- DrawTimeBar();
-
- temp = myPt.h;
- }
- }while( Button());
- break;
-
- case 21: PressTypeMenu( 129, whichItem); break;
- case 23: PressTypeMenu( 128, whichItem); break;
- case 30: PressTypeMenu( 130, whichItem); break;
- case 8: PressTypeMenu( 165, whichItem); break;
- case 25: PressTypeMenu( 170, whichItem); break;
- case 28: PressTypeMenu( 169, whichItem); break;
- case 11: PressTypeMenu( 131, whichItem); break;
- case 14: PressTypeMenu( 132, whichItem); break;
- case 17: PressTypeMenu( 133, whichItem); break;
- }
-
- SetPort( savePort);
- }
- break;
-
- case inGoAway:
- if( TrackGoAway( whichWindow, theEvent.where)) OnTourne = false;
- break;
-
- case inDrag:
- DragWindow( whichWindow, theEvent.where, &qd.screenBits.bounds);
- break;
-
- case inSysWindow:
- SystemClick( &theEvent, whichWindow);
- break;
-
- case inZoomIn:
- case inZoomOut:
- if( TrackBox( whichWindow, theEvent.where, thePart))
- {
- if( whichWindow->portRect.bottom > 43) SizeWindow( whichWindow, whichWindow->portRect.right, 43, true);
- else SizeWindow( whichWindow, whichWindow->portRect.right, 153, true);
- }
- break;
- }
- }
- else if( theEvent.what == updateEvt)
- {
- BeginUpdate( myDialog);
- DrawDialog( myDialog);
- SetPort( myDialog);
-
- /*** Volume ***/
- GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
- itemRect.left-=1; //itemRect.right+=1;
- itemRect.top-=1; //itemRect.bottom+=1;
- FrameRectRelief( &itemRect);
-
- GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
- Location.h = VolumeH + itemRect.left;
- itemRect.right = Location.h;
- PaintRect( &itemRect);
- GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
- itemRect.left = Location.h;
-
- ForeColor( whiteColor);
- PaintRect( &itemRect);
- ForeColor( blackColor);
-
- /**/
-
- GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
- MoveTo( itemRect.left + 2, itemRect.bottom - 1);
- TextMode( srcXor);
- NumToString( VolumeH, aStr); pStrcat( aStr, "\p %");
- DrawString( aStr);
- TextMode( srcCopy);
-
- /**/
- /*****/
-
- /*** Speed **/
-
- GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
- itemRect.left-=1; //itemRect.right+=1;
- itemRect.top-=1; //itemRect.bottom+=1;
- FrameRectRelief( &itemRect);
-
- GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
- Location.h = SpeedH + itemRect.left;
- itemRect.right = Location.h;
- PaintRect( &itemRect);
- GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
- itemRect.left = Location.h;
-
- ForeColor( whiteColor);
- PaintRect( &itemRect);
- ForeColor( blackColor);
-
- /**/
-
- GetDialogItem (myDialog, 18, &itemType, &itemHandle, &itemRect);
- MoveTo( itemRect.left + 2, itemRect.bottom - 1);
- TextMode( srcXor);
- NumToString( SpeedH*2, aStr); pStrcat( aStr, "\p %");
- DrawString( aStr);
- TextMode( srcCopy);
-
- /**/
-
- /*** Position ***/
- GetDialogItem (myDialog, 4, &itemType, &itemHandle, &itemRect);
- itemRect.left-=1; //itemRect.right+=1;
- itemRect.top-=1; //itemRect.bottom+=1;
- FrameRectRelief( &itemRect);
-
- DrawTimeBar();
- /*****/
-
-
- EndUpdate( myDialog);
- }
- else if( theEvent.what == keyDown)
- {
- theChar=theEvent.message & charCodeMask;
-
- if ((theEvent.modifiers & cmdKey) !=0)
- {
- if( theChar =='Q' ||
- theChar =='q' ||
- theChar == 'w' ||
- theChar == 'W' ||
- theChar =='f' ||
- theChar == 'F')
-
- OnTourne = false;
- }
- }
- else if( theEvent.what == kHighLevelEvent) AEProcessAppleEvent (&theEvent);
- }while( OnTourne == true);
- }
-
- extern Boolean Reading;
-
- void MusiqueDriverInit(void)
- {
- OSErr iErr;
- MADDriverSettings init;
-
- init.numChn = 4;
- init.outPutBits = thePrefs.outPutBits;
- init.outPutRate = thePrefs.outPutRate;
- init.outPutMode = thePrefs.outPutMode;
- init.driverMode = thePrefs.driverMode;
- init.antiAliasing = thePrefs.antiAliasing;
- init.sysMemory = true;
- init.repeatMusic = true;
- init.surround = thePrefs.surround;
- init.Interpolation = thePrefs.Interpolation;
- init.MicroDelay = thePrefs.MicroDelay;
- init.MicroDelaySize = thePrefs.MicroDelaySize;
- init.Reverb = thePrefs.Reverb;
- init.ReverbSize = thePrefs.ReverbSize;
- init.ReverbStrength = thePrefs.ReverbStrength;
- init.TickRemover = thePrefs.TickRemover;
-
- if( init.driverMode == ASCSoundDriver || init.driverMode == AWACSoundDriver)
- init.driverMode = SoundManagerDriver;
-
- iErr = MADCreateDriver( &init);
- if( iErr) MyDebugStr( "\pMusicDriver ERROR !");
- }
-
- void DoPreferences2()
- {
- OSErr iErr;
- short vRefNum, fRefNum, SvRefNum;
- long DirID, inOutBytes, SdirID;
- Boolean initOK;
-
- HGetVol( 0L, &SvRefNum,&SdirID);
-
- initOK = false;
-
- iErr = FindFolder( kOnSystemDisk, kPreferencesFolderType, kCreateFolder, &vRefNum, &DirID);
-
- iErr = HSetVol( 0L, vRefNum, DirID);
-
- iErr = FSOpen( PLAYERPREF, 0, &fRefNum);
- if( iErr == noErr)
- {
- inOutBytes = sizeof( Prefs);
- iErr = FSRead( fRefNum, &inOutBytes, &thePrefs);
- iErr = FSClose( fRefNum);
-
- if( thePrefs.Version != VERSION)
- {
-
- }
- else
- {
- MusiqueDriverInit();
- initOK = true;
- }
- }
-
- if( initOK == false)
- {
- OSErr iErr;
- MADDriverSettings init;
-
- init.numChn = 4;
- init.outPutBits = 8;
- init.outPutRate = rate22khz;
- init.outPutMode = MonoOutPut;
- init.driverMode = SoundManagerDriver;
- init.antiAliasing = false;
- init.sysMemory = true;
- init.repeatMusic = true;
- init.surround = true;
- init.Interpolation = true;
- init.MicroDelay = false;
- init.MicroDelaySize = 0;
- init.Reverb = false;
- init.ReverbSize = 0;
- init.ReverbStrength = 0;
- init.TickRemover = false;
-
- iErr = MADCreateDriver( &init);
- if( iErr) MyDebugStr( "\pMusicDriver ERROR !");
- }
-
- HSetVol( 0L, SvRefNum, SdirID);
- }
-
- void main()
- {
- long gestaltAnswer;
- int myBit, OldVol;
- short itemType;
- Rect itemRect;
- Handle itemHandle;
- Point Svolume;
-
-
- InitGraf( &qd.thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- TEInit();
- InitMenus();
- InitCursor();
- MaxApplZone();
-
- oldTempL = -100;
- OnTourne = true;
- MADInitLibrary("Plugs", true);
- MADDriver = MADGetMADDriverPtr();
-
- workPixPat = GetPixPat( 130);
-
- InstallAE();
-
- myDialog = GetNewDialog( 3214,0L, (WindowPtr) -1L);
- SizeWindow( myDialog, myDialog->portRect.right, 43, true);
- ShowWindow( myDialog);
- SetPort( myDialog);
- TextFont( geneva);
- TextSize( 9);
-
- GetDialogItem ( myDialog, 1, &itemType, &itemHandle, &itemRect);
-
- Gestalt( gestaltSoundAttr, &gestaltAnswer);
- myBit = gestaltStereoCapability;
- Stereo = BitTst( &gestaltAnswer, 31-myBit);
-
- myBit = gestalt16BitSoundIO;
- has16Bit = BitTst( &gestaltAnswer, 31-myBit);
-
- NewSoundManager = true;
-
- if( NewSoundManager)
- {
- GetDefaultOutputVolume( (long*) &Svolume);
- Svolume.h /= 32;
- OldVol = Svolume.h - 1;
- }
- else
- {
- GetSoundVol((void *)&OldVol);
- }
- GetDialogItem (myDialog, 2, &itemType, &itemHandle, &itemRect);
- VolumeH = (OldVol + 1)*( itemRect.right - itemRect.left) / 8;
- SpeedH = 50;
-
- SetWTitle( myDialog, LMGetCurApName());
-
- DoPreferences2();
-
- InitDriverString();
-
- if( MADLoadMusicRsrc( 'MADH', 3214) != noErr)
- {
- ExitToShell();
- }
-
- #ifndef THINK_C
- MyTrackingUPP = NewDragTrackingHandlerProc( MyTrackingTools);
- MyReceiveUPP = NewDragReceiveHandlerProc( MyReceiveTools);
-
- InstallTrackingHandler( (DragTrackingHandler) MyTrackingUPP, myDialog, (void *) 0L);
- InstallReceiveHandler( (DragReceiveHandler) MyReceiveUPP, myDialog, (void *) 0L);
- #endif
-
-
- /* Music is turn ON !! */
-
- MADStartDriver();
- MADDriver->Reading = true;
-
- MegaLoop();
-
- SetUpSize();
-
- MADStopDriver();
- MADDisposeMusic();
- MADDisposeDriver();
- MADDisposeLibrary();
-
- FlushEvents( everyEvent, 0);
- ExitToShell();
- }
-
-